#include "dominion.h"
#include "dominion_helpers.h"
#include "testutils.h"
#include <stdio.h>
#include <stdlib.h>

// This unit test was added after it was found (via random testing, confirmed
// with code inspection) that the salvager card would refuse to salvage 
// anything from the first slot within the player's hand. All combinations of
// card positions and salvaged cards are tested.

void testSalvagerEffect 
                    (   int args[MAX_PLAYARGS], int cardtypes[MAX_PLAYARGS],
                        carddesc_t desc, struct gameState *g,
                        expectedState_t *expected )
{
    expected->count[cardtypes[1]]--;
    int expectedBuys = g->numBuys + 1;
    int expectedCoins = g->coins + getCost (cardtypes[1]);
    
    pass_printf (   "%s: TEST salvaging %s using %s\n", 
                    __func__, desc[1], desc[0] );
    
    testPlayCard (args[0], args[1], args[2], args[3], g, expected, false);
    
    assert_equal (g->numBuys, expectedBuys, "verifying the number of buys");
    assert_equal (g->coins, expectedCoins, "verifying the number of coins");
    
    testEndTurn (g, expected);
}

int main (int argc, char *argv[])
{
    parse_args (argc, argv);
    
    static playargs_t playargs =
    {
        {arg_handcard,  salvager, salvager},
        {arg_handcard,  0, treasure_map},
    };
    
    run_cardtest (playargs, testSalvagerEffect);
    
}
